/***************************************************************************
 *   Copyright (C) 2009 by Philipp Müller                                  *
 *   philipp.mueller@gmx.de                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
 ***************************************************************************/

#ifndef WIDGETRECORDINGSLIDER_H
#define WIDGETRECORDINGSLIDER_H

#include <QWidget>
#include <QTimer>


class WidgetRecordingSlider : public QWidget
{
        Q_OBJECT

public:
        WidgetRecordingSlider( QWidget * parent );
        ~WidgetRecordingSlider();


signals:
        /** Signals the new position in seconds */
        void newPos( quint32 );


public slots:
        /** Sets the length in seconds */
        void setLength( qint32 length );

        /** Sets the current position in milliseconds. Milliseconds in order to use some time in future MediaObject::tick( quint64 ) */
        void setPos( qint64 pos );

        /** Sets the current end of recording in seconds */
        void setCurrentEnd( qint32 end );


private slots:
        void updateView();


private:
        void mousePressEvent( QMouseEvent *event );
        void paintEvent( QPaintEvent * event );
        qint32 timeFromPixel( int pixel );
        int pixelFromTime( qint32 time );

        qint32 m_length;
        qint32 m_pos;
        qint32 m_currentEnd;
        QTimer m_timer;
};

#endif
